import { http } from "@/utils/http";

/** 登录日志模型定义 */
export type LoginLogModel = {
  infoId: number;
  loginName: string;
  ipaddr: string;
  loginLocation: string;
  browser: string;
  os: string;
  status: number;
  msg: string;
  loginTime: string;
};

/** 登录日志分页查询参数 */
export interface LoginLogPageParams extends IReqPagerData {
  userName?: string;
  ipAddr?: string;
  status?: string;
  beginTime?: string;
  endTime?: string;
}

/** 分页获取登录日志列表 */
export const getLoginlogListApi = (data: LoginLogPageParams) => {
  return http.request<Resp<IRespPagerData<LoginLogModel>>>(
    "get",
    "/login-log/page-list",
    { params: data }
  );
};

/** 获取登录日志详情 */
export const getLoginlogByIdApi = (infoId: number) => {
  return http.request<Resp<{
    info: LoginLogModel
  }>>('get', `/login-log/${infoId}`);
};

/** 新增登录日志 */
export const addLoginlogApi = (data: Partial<LoginLogModel>) => {
  return http.request<Resp<{ infoId: number }>>("post", "/login-log", { data });
};

/** 删除登录日志 */
export const deleteLoginlogApi = (infoId: number) => {
  return http.request<Resp<{ rows: number }>>("delete", `/login-log/${infoId}`);
};

/** 批量删除登录日志 */
export const batchDeleteLoginlogApi = (infoIds: number[]) => {
  return http.request<Resp<{ rows: number }>>("delete", "/login-log/batch-del", {
    data: { infoIds }
  });
};